﻿/******************************************************************************
 * Name			: WSAInitialize.hpp
 * Author		: 671643387
 * Date			: 2015年9月18日
 * Description	:
 *****************************************************************************/

#ifndef COMMON_NET_WSAINITIALIZE_HPP_
#define COMMON_NET_WSAINITIALIZE_HPP_

#if !defined(_WINSOCK_DEPRECATED_NO_WARNINGS)
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif

#include <boost/noncopyable.hpp>
#include <WinSock2.h>

namespace sxr
{
	namespace common
	{
		class WSAInitialize : public boost::noncopyable
		{
		public:
			WSAInitialize(void)
			{
				WSADATA wsaData;
				WSAStartup(MAKEWORD(2, 2), &wsaData);
			}

			~WSAInitialize(void)
			{
				WSACleanup();
			}
		};
	}
}

#endif /* COMMON_NET_WSAINITIALIZE_HPP_ */
